package net.hn.hnms.sys.common.mybatis.config;

import net.hn.hnms.sys.common.core.utils.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 功能描述: MybatisPlus华能煤矿编码的自动配置,
 *
 * @auther: WangLong
 * @date: 2022/11/14 11:22
 */

@Configuration
//@ConditionalOnProperty(prefix = "mybatis.huaneng.mineCode", name = "enable",havingValue = "true",matchIfMissing = true)
//@EnableConfigurationProperties(MybatisMineCodeConfiguration.MineCode.class)
public class MybatisMineCodeConfiguration {

    @Value("${mybatisPlus.huaneng.mineCode.meiye}")
    private String meiye;
    @Value("${mybatisPlus.huaneng.mineCode.huating}")
    private String huating;
    @Value("${mybatisPlus.huaneng.mineCode.yanbei}")
    private String yanbei;
    @Value("${mybatisPlus.huaneng.mineCode.beineng}")
    private String beineng;
    @Value("${mybatisPlus.huaneng.mineCode.huajian}")
    private String huajian;
    @Value("${mybatisPlus.huaneng.mineCode.weijiamao}")
    private String weijiamao;
    @Value("${mybatisPlus.huaneng.mineCode.gaotouyao}")
    private String gaotouyao;
    @Value("${mybatisPlus.huaneng.mineCode.zhamei}")
    private String zhamei;
    @Value("${mybatisPlus.huaneng.mineCode.linglu}")
    private String linglu;
    @Value("${mybatisPlus.huaneng.mineCode.qingyang}")
    private String qingyang;
    @Value("${mybatisPlus.huaneng.mineCode.hetaoyu}")
    private String hetaoyu;
    @Value("${mybatisPlus.huaneng.mineCode.lingdong}")
    private String lingdong;
    @Value("${mybatisPlus.huaneng.mineCode.lingquan}")
    private String lingquan;
    @Value("${mybatisPlus.huaneng.mineCode.tiebei}")
    private String tiebei;
    @Value("${mybatisPlus.huaneng.mineCode.xichuan}")
    private String xichuan;
    @Value("${mybatisPlus.huaneng.mineCode.default}")
    private String defaultCode;
    @Value("${mybatisPlus.huaneng.mineCode.enable}")
    private String enable;

    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "meiye", matchIfMissing = false)
    public MineCode setMineCodeMeiYe() {
        return new MineCode(this.meiye,this.enable);
    }
    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "huating", matchIfMissing = false)
    public MineCode setMineCodeHuaTing() {
        return new MineCode(this.huating,this.enable);
    }
    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "yanbei", matchIfMissing = false)
    public MineCode setMineCodeYanBei() {
        return new MineCode(this.yanbei,this.enable);
    }
    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "beineng", matchIfMissing = false)
    public MineCode setMineCodeBeiNeng() {
        return new MineCode(this.beineng,this.enable);
    }
    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "huajian", matchIfMissing = false)
    public MineCode setMineCodeHuaJian() {
        return new MineCode(this.huajian,this.enable);
    }
    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "weijiamao", matchIfMissing = false)
    public MineCode setMineCodeWeiJiaMao() {
        return new MineCode(this.weijiamao,this.enable);
    }
    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "gaotouyao", matchIfMissing = false)
    public MineCode setMineCodeGaoTouYao() {
        return new MineCode(this.gaotouyao,this.enable);
    }

    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "zhamei", matchIfMissing = false)
    public MineCode setMineCodeZhaMei() {
        return new MineCode(this.zhamei,this.enable);
    }

    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "linglu", matchIfMissing = false)
    public MineCode setMineCodeLingLu() {
        return new MineCode(this.linglu,this.enable);
    }
    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "qingyang", matchIfMissing = false)
    public MineCode setMineCodeQingYang() {
        return new MineCode(this.qingyang,this.enable);
    }

    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "hetaoyu", matchIfMissing = false)
    public MineCode setMineCodeHeTaoYu() {
        return new MineCode(this.hetaoyu,this.enable);
    }
    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "lingdong", matchIfMissing = false)
    public MineCode setMineCodeLingDong() {
        return new MineCode(this.lingdong,this.enable);
    }

    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "lingquan", matchIfMissing = false)
    public MineCode setMineCodeLingQuan() {
        return new MineCode(this.lingquan,this.enable);
    }

    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "tiebei", matchIfMissing = false)
    public MineCode setMineCodeTieBei() {
        return new MineCode(this.tiebei,this.enable);
    }
    @Bean
    @ConditionalOnProperty(prefix = "mybatisPlus.huaneng.mineCode", name = "enable",havingValue = "xichuan", matchIfMissing = false)
    public MineCode setMineCodeXiChuan() {
        return new MineCode(this.xichuan,this.enable);
    }

    @Bean
    @ConditionalOnMissingBean
    public MineCode setMineCodeDefault() {
        return new MineCode(this.defaultCode);
    }


    public class MineCode{
       private String code;
       private String enable;

       public MineCode() {
       }

       public MineCode(String code) {
           if (StringUtils.isEmpty(code)) {
               this.code = "000000000000";
           }
           this.code = code;
       }

        public MineCode(String code, String enable) {
            if (StringUtils.isEmpty(code)) {
                this.code = "000000000000";
            }
            this.code = code;
            this.enable = enable;
        }

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getEnable() {
            return enable;
        }

        public void setEnable(String enable) {
            this.enable = enable;
        }
    }
}

